//Model 2 of the 3D tutorial
 model TEST_DYNAMIC_MODEL_INTERACTIVE

global
{
	int nb_cells <- 50;
	int environmentSize <- 100;	
 
 	init
	{
		create cells number: nb_cells
		{
			location <- { rnd(environmentSize), rnd(environmentSize), rnd(environmentSize) };
		}
	}

}

species cells skills: [moving3D]
{
	float radius <- environmentSize * 0.01;
	rgb color <- rgb(rnd(255), rnd(255), rnd(255));
	list<cells> neighbours;
	reflex move
	{
		do wander_3D;
	}

	reflex computeNeighbours
	{
		neighbours <- cells select ((each distance_to self) < 15);
	}

	aspect default
	{
		draw sphere(radius) color: color;
		loop pp over: neighbours
		{
			/** I CAN NOT IMPLEMENT THIS LINE :(  */
			//draw line([self.location, pp.location]);
 			
 			set pp.color <- self.color;
		}
	}
}

experiment DYNAMIC_MODEL_INTERACTIVE type: gui
{
	output
	{
		display View1 type: java3d
		{
 			species cells;
		}
	}
}